"""modify AI_Modeld

Revision ID: 306aa915e6b0
Revises: 7dde9a452963
Create Date: 2025-05-01 16:00:14.125122

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision: str = '306aa915e6b0'
down_revision: Union[str, None] = '7dde9a452963'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('ai_agents', 'system_prompt',
               existing_type=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               type_=sa.TEXT(length=16777216),
               existing_comment='系统提示词',
               existing_nullable=True)
    op.add_column('ai_model', sa.Column('type', sa.String(length=16), server_default=sa.text("'llama_index'"), nullable=False, comment='类型'))
    op.add_column('ai_model', sa.Column('has_tool', sa.String(length=16), server_default=sa.text("'YES'"), nullable=False, comment='是否支持tool'))
    op.alter_column('funcall_log', 'log_text',
               existing_type=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               type_=sa.TEXT(length=16777216),
               existing_comment='日志信息',
               existing_nullable=True)
    op.alter_column('tools', 'tool_desc',
               existing_type=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               type_=sa.TEXT(length=16777216),
               existing_nullable=True)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('tools', 'tool_desc',
               existing_type=sa.TEXT(length=16777216),
               type_=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               existing_nullable=True)
    op.alter_column('funcall_log', 'log_text',
               existing_type=sa.TEXT(length=16777216),
               type_=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               existing_comment='日志信息',
               existing_nullable=True)
    op.drop_column('ai_model', 'has_tool')
    op.drop_column('ai_model', 'type')
    op.alter_column('ai_agents', 'system_prompt',
               existing_type=sa.TEXT(length=16777216),
               type_=mysql.LONGTEXT(collation='utf8mb4_general_ci'),
               existing_comment='系统提示词',
               existing_nullable=True)
    # ### end Alembic commands ###
